<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    {js href='/public/static/jquery/jquery-1.11.0.min.js' /}
    {js href='/public/static/layui/layui.js' /}
    {CSS href="/public/static/layui/css/layui.css" /}
    {CSS href="__ADDONSTATIC__/css/style.css" /}
</head>
<body>
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

    <div class="layui-tab-content">
<div class="forms-content">
    <form name="form2" class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">轮播图描述</label>
            <div class="layui-input-block">
                <input type="text" name="describe" value="{$form.describe}" required lay-verify="required" placeholder="请输入名称" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">轮播图片</label>
            <div class="layui-input-block">
                {:hook('Upload',['type'=>'image','name'=>'img_path','value'=>$form.img_path,'material'=>true])}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input name="sort" placeholder="请输入排序" autocomplete="off" class="layui-input" type="text" value="{$form.sort}">
            </div>
            <div class="layui-form-mid layui-word-aux">数字越小越靠前</div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">显示状态</label>
            <div class="layui-input-block">
                <input type="checkbox" {if condition="$form.show == 1"}checked{/if} lay-skin="switch" name="show">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">轮播图链接地址</label>
            <div class="layui-input-block">
                <input type="text" name="url" value="{$form.url}" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                <a href="{:addonUrl('index',['type'=>2])}" class="layui-btn layui-btn-primary">返回</a>
            </div>
        </div>
    </form>
</div>
    </div>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form;
        var layer = layui.layer;

        form.on('submit(formDemo)', function (data) {
            var loadIndex = layer.load(1);
            $.post('', data.field, function (res) {
                layer.close(loadIndex);
                parent.layer.msg(res.msg);
                if(res.status == 1){
                    location.href="{:addonUrl('index',['type'=>2])}";
                }
            }).error(function (error) {
                parent.layer.alert('500 Internal Server Error');
                layer.close(loadIndex)
            })
            return false;
        });
    });
</script>
</body>
</html>